package server.datamodel;

public class User {

	private String ID;
	private Team team;
	private String nickname;
	private UserAssets userAssets;
	
	public User() {
		this.ID = Datamodel.generateID(this);
	}
	
	@Override
	public String toString() {
		return ID;
	}
	
	public UserAssets getUserAssets() {
		return userAssets;
	}
	
	public void setUserAssets(UserAssets userAssets) {
		if(this.userAssets != userAssets) {
			if(getUserAssets() != null) {
				UserAssets oldUserAssets = getUserAssets();
				this.userAssets = null;
				oldUserAssets.setUser(null);
			}
			this.userAssets = userAssets;
			if(getUserAssets() != null) {
				getUserAssets().setUser(this);
			}
		}
	}
	
	public void setTeam(Team team) {
		if(this.team != team) {
			if(getTeam() != null) {
				getTeam().removeUser(this);
			}
			this.team= team;
			if(getTeam() != null) {
				getTeam().addUser(this);
			}
		}
	}
	
	public Team getTeam() {
		return team;
	}

	public String getID() {
		return ID;
	}

	public void setID(String iD) {
		ID = iD;
	}

	public String getNickname() {
		return nickname;
	}

	public void setNickname(String nickname) {
		this.nickname = nickname;
	}

//	public Tile getTile() {
//		return tile;
//	}

//	public void setTile(Tile tile) {
//		if(this.tile != tile) {
//			if(getTile() != null) {
//				Tile oldTile = getTile();
//				this.tile = null;
//				oldTile.setUser(null);
//			}
//			this.tile = tile;
//			if(getTile() != null) {
//				getTile().setUser(this);
//			}
//		}
//	}
	
}
